import axios from "axios";
import { useEffect, useState } from "react";

interface ListRawState {
  id: string
  title: string
  key: string
  word: string
  image: string
  price: string
  datetime: string
}
export function useList() {
  const [list, setList] = useState<ListRawState[]>([]);
  const [searchValue, setSearchValue] = useState('')
  const getList = async () => {
    const resp = await axios.get('/xx/list', { params: { q: searchValue } });
    setList(resp.data)
  }

  useEffect(() => {
    getList()
  }, [searchValue])

  return { list, getList, setSearchValue }
}